﻿using System;
using System.Collections.Generic;
using FrontRoomCheck.Model;
using FrontRoomCheck.Utiltiy;
using ModelCheckUtility.ModelLayer;

namespace FrontRoomCheck.SpecialUse
{
	public class FrontRoomCheck_CmdFrontRoomSurfaceCheck : IFrontRoomCheck<ICloseCurveAnalays>, IPackerCheck<ICloseCurveAnalays>, IBase<ICloseCurveAnalays>
	{
		public FrontRoomCheck_CmdFrontRoomSurfaceCheck()
		{
			this.rules = XmlManger.GetStandardXmlValue();
		}

		public List<ICloseCurveAnalays> CheckPackers(List<ICloseCurveAnalays> input, params object[] otherValues)
		{
			List<ICloseCurveAnalays> list = new List<ICloseCurveAnalays>();
			return input;
		}

		public bool doCheckFrontChamberStandard(ICloseCurveAnalays input)
		{
			bool flag = true;
			List<double> list = new List<double>();
			foreach (FrontChamberStandardRule frontChamberStandardRule in this.rules)
			{
				flag = true;
				if (input.RoomType == frontChamberStandardRule.RoomType)
				{
					if (input.BuildingType == frontChamberStandardRule.BuildingType && input.BuildingType == StaticRescource.BuildingTypes[0])
					{
						for (int i = 0; i < frontChamberStandardRule.StandardRule.Count; i++)
						{
							list.Add(frontChamberStandardRule.StandardRule[StaticRescource.StandardAttributeNames[i]]);
						}
						flag = (Utility.ChangeAreaByUnit(input.GetArea()) >= list[0] && input.AppendValue >= list[1] && flag);
						return flag;
					}
					if (input.BuildingType == frontChamberStandardRule.BuildingType && input.BuildingType == StaticRescource.BuildingTypes[1])
					{
						for (int j = 0; j < frontChamberStandardRule.StandardRule.Count; j++)
						{
							list.Add(frontChamberStandardRule.StandardRule[StaticRescource.StandardAttributeNames[j]]);
						}
						flag = (Utility.ChangeAreaByUnit(input.GetArea()) >= list[0] && input.AppendValue >= list[1] && flag);
						return flag;
					}
				}
			}
			return flag;
		}

		private List<FrontChamberStandardRule> rules = new List<FrontChamberStandardRule>();
	}
}
